# -*- coding: utf-8 -*-
"""
汽车由发动机，轮胎，车架，底盘组成，
有外观，价格，油耗等属性
有启动，停止，鸣笛等方法。用oo的思想定义汽车类，并测试。
"""

class Car:
    def __init__(self, appearance, price, fuel, engine, tires, frame, chassis):
        """
        appearance : 汽车外观描述
        price: 汽车价格（万元）
        fuel: 百公里油耗（升）
        engine: 发动机型号
        tires: 轮胎型号
        frame: 车架型号
        chassis: 底盘型号
        """
        
        self.appearance = appearance
        self.price = price
        self.fuel = fuel
        self.engine = engine
        self.tires = tires
        self.frame = frame
        self.chassis = chassis
        self.is_running = False
    
    def start(self):
        """启动汽车"""
        if not self.is_running:
            self.is_running = True
            print(f"{self.appearance}汽车已启动，{self.engine}发动机开始工作")
        else:
            print("汽车已经在运行中")
    
    def stop(self):
        """停止汽车"""
        if self.is_running:
            self.is_running = False
            print("汽车已停止")
        else:
            print("汽车已经处于停止状态")
    
    def beep(self):
        """鸣笛"""
        print("嘀嘀嘀！")
    
    def display_info(self):
        """显示汽车信息"""
        print(f"\n===== {self.appearance}汽车信息 =====")
        print(f"价格: {self.price}万元")
        print(f"油耗: {self.fuel}L/100km")
        print(f"发动机: {self.engine}")
        print(f"轮胎: {self.tires}")
        print(f"车架: {self.frame}")
        print(f"底盘: {self.chassis}")
        print(f"当前状态: {'运行中' if self.is_running else '已停止'}")


if __name__ == "__main__":
    
    car = Car(
        appearance="红色轿车",
        price=15.8,
        fuel=6.5,
        engine="1.5T涡轮增压",
        tires="米其林215/55 R17",
        frame="高强度钢车架",
        chassis="独立悬挂底盘"
    )
    
    # 显示汽车信息
    car.display_info()
    
   
    print("\n测试汽车功能:")
    car.start()   
    car.beep()    
    car.start()   
    car.stop()    # 
    car.stop()    
    
    